package com.cloud.logger.zchain.core.common.properties;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by Administrator on 2017/12/16.
 */
public enum ServerInfo {

    INSTANCE;

    private static String IP_STR = "ip";

    private static String POER_STR = "port";

    public static String ip;

    public static int port;

    public static String scenic;

    public static String project;

    public static byte[] ipPortByte;

    public static String ipPortStr;

    public static String scheduleNode;

    public static String serverNode;

    // 分布式预留字段
    public static Map<String,String> distributed_scheduleNode = new ConcurrentHashMap<String,String>();

    public static void setIp(String ip) {
        ServerInfo.ip = ip;
        setIpPortByte();
    }

    public static void setPort(int port) {
        ServerInfo.port = port;
        setIpPortByte();
    }

    public static void setIpPortByte() {
        String ipandportStr = IP_STR+ip+POER_STR+port;
        ipPortStr = ipandportStr;
        ipPortByte =(ipandportStr == null ? null : ipandportStr.getBytes());
    }

    public static void setScheduleNode(String scheduleNode) {
        ServerInfo.scheduleNode = scheduleNode;
    }

    public static void setServerNode(String serverNode) {
        ServerInfo.serverNode = serverNode;
    }

    public static void setScenic(String scenic) {
        ServerInfo.scenic = scenic;
    }

    public static void setProject(String project) {
        ServerInfo.project = project;
    }
}
